<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>
    var obj = {
        name:"Admin",
        age:18,
        sex:"男"
    };

    // 浅拷贝
    // var obj2 = obj;

    // 深拷贝：遍历
    var obj2 = {};
    // obj2.name = obj.name;
    // obj2.age = obj.age;
    // obj2.sex = obj.sex;

    // for-in专门用来遍历非数组对象
    for(var i in obj){
        obj2[i] = obj[i];
    }

    obj2.name = "root";

    console.log(obj)
    console.log(obj2)
</script>
</html>